Ext.namespace("SMeeting");

SMeeting.Fulfill = function (p){
	this.parentWin=p
	
	this.hdSuperviseId = new Ext.form.Hidden({name:'superviseId'});
	this.txtTitle = new Ext.form.TextField({
        fieldLabel: '公文名称',
        name:'superviseTitle',
        width: 340,
        disabled:true
    });
	this.txtManagerId=new Ext.form.Hidden({name:'managerId'});
	this.txtManagerName = new Ext.form.TextField({
		fieldLabel: '阅处负责人',
		name:'managerName',
		width: 120,
		disabled: true
	});
	this.txtIssueDate = new Ext.form.TextField({
    	fieldLabel: '批示日期',
    	name:'issueDate',
		disabled:true,
		width:120
	});
	
	this.txtNotion = new Ext.form.TextArea({
		fieldLabel: '领导批示意见',
		name:'notion',
		width: 540,
		height: 35,
		disabled:true
	});
	this.txtFulfill = new Ext.form.TextArea({
		fieldLabel: '落实情况',
		name:'fulfill',
		width: 540,
		height: 45,
		maxLength:1000
	});
	this.btnSave = new Ext.Button({
    	text:'保存',
    	handler:this.onSave,
    	scope: this
    });
	this.form = new Ext.form.FormPanel({
		bodyStyle: 'padding: 5px 5px 0',
        frame:true,
        labelWidth: 70,
		labelAlign:'right',
		region:'north',	
		height: 155,	
		split:true,
		collapsible: true,
		items:[this.txtManagerId,this.hdSuperviseId,
        	{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .66, items: [this.txtTitle]}]
	    },{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .33, items: [this.txtManagerName]},
	        	         { columnWidth: .33, items: [this.txtIssueDate]}]
	    },this.txtNotion,this.txtFulfill]
	});
	
	this.store2 = new Ext.data.JsonStore({
	    url: '../superviseMeeting/listMeetingTask.form?timesnap=' + Date.parse(new Date()),
	    root: 'result',
	    totalProperty: 'total',
        remoteSort: true,
	    fields: ['auditId','superviseId','auditContent','auditorId','auditDate',
	    'auditState','inspectorId','inspectorName','dispatchDate','taskContent','backContent','completeDate',
	    'content','auditorName','finishDate','taskStatus']
	});
	//this.store.setDefaultSort('taskFeedbackId', 'desc');
	this.renderTaskStatus = function(value){
		return OMS.TASKSEXESTATUS[value];
	}
	this.renderState = function(value){
		return OMS.TASKSTATUS[value];
	};
	this.renderSend = function(value){
		
	}
	this.columns2 = [	
		{header: '派发ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'auditId'},
		{header: '督办ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'superviseId'},
		{header: '派发意见', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'auditContent'},
		{header: '阅处人ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'auditorId'},
		{header: '阅处人', sortable: true, align: 'center',width: 20,dataIndex: 'auditorName'},
		{header: '任务派发时间', sortable: true, align: 'right',width: 20,dataIndex: 'dispatchDate'},
		{header: '反馈日期', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'auditDate'},
		{header: '完成时间', sortable: true, align: 'right',width: 30,dataIndex: 'finishDate'},
		{header: '反馈状态', sortable: true, align: 'center',width: 20,dataIndex: 'taskStatus',renderer:this.renderState},
		{header: '阅处人id', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorId'},
		{header: '阅处人名称', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorName'},		
		{header: '任务要求', sortable: true, align: 'center',width: 30,dataIndex: 'taskContent'},
		{header: '反馈情况', sortable: true, align: 'center',width: 30,dataIndex: 'backContent'},
		{header: '完成期限', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'completeDate'},
		{header: '操作', align: 'center',width: 30,dataIndex: 'auditId',
			renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){
				return '';
			}

		}
	];
	this.grid2 = new Ext.grid.GridPanel({
		title:'任务派发情况',
		region: 'center',
		cm: new Ext.grid.ColumnModel(this.columns2),
		store:this.store2,
		height: 180,
		viewConfig: { forceFit: true },
        collapsible:true
	});	
	SMeeting.Fulfill.superclass.constructor.call(this,{
		title: '任务督办反馈',
		width:700,
		height:420,
		resizable: false,
        modal: true,
        autoScroll: true,
		closeAction:'hide',
		items:[this.form,this.grid2],
		buttonAlign:'center',
		buttons:[this.btnSave,{
            text: '关闭',
            scope: this,
            handler: function() {
	        	this.hide();
        	}
        }]
	});	
};

Ext.extend(SMeeting.Fulfill, Ext.Window, {
	initWin:function(data){
		this.form.getForm().setValues(data);
		this.grid2.store.load({
			params:{superviseId:data.superviseId}
		});	
	},
	onSave: function() {
		if(!this.form.getForm().isValid()){
			Utils.info2("有必填项没有填写，请检查！",180);
			return;
		}
		var conn = new Ext.data.Connection({
  			url:'../superviseMeeting/fulfill.form?timesnap=' + Date.parse(new Date()),
  			method:'post'
  		})
  		var param={superviseId:this.hdSuperviseId.getValue(),
  					fulfill:this.txtFulfill.getValue()};
  		//alert(Ext.util.JSON.encode(param));		
		Utils.request(conn,{
  			params:param,
  			scope:this,
  			success:function(data){
  				Utils.info2();
				this.scope.hide();
				this.scope.parentWin.queryDoc();
  			}
  		});
  		this.parentWin.queryDoc();
  		this.hide();
	}
});